﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CommandLib;
using FindArtInfo.Models;
using Resources;

namespace FindArtInfo.Controllers
{
    public class MailFriendController : Controller
    {
        //
        // GET: /MailFriend/

        public ActionResult Index()
        {
            PageMailFriendModel model = new PageMailFriendModel();
            return View(model);
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Index(PageMailFriendModel model)
        {
            string subject = "Your friend " + model.YourName + " recommends www.FindArtInfo.com";
            string content = "<font face='Verdana' size=2><p>Hi " + model.FriendName + "<P>" + model.Message +
                          "<p>Best regards<p>" + model.YourName +
                          "<hr size='1'>Visit <a href='http://www.FindArtInfo.com'>www.FindArtInfo.com</a> and value your piece of art by comparing with recent auction prices of similar pieces. It&rsquo;s free.<hr size='1'>";
            int result = Utils.SendMail(Config.FromEmail, Config.DiplayFromName, Config.PassFromEmail, model.FriendEmail,
                                        model.FriendEmail, Config.EmailCC, subject, content, Config.Host, Convert.ToInt32(Config.Port));
            ModelState.AddModelError("MessageResult", string.Format(Multi.PageMailFriendSuccess, model.FriendName));
            model.MessageResult = Multi.PageMailFriendSuccess;
            return View(model);
        }

    }
}
